package com.ddyx.common.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

public class LoginResponse {
	private static final String STATUS = "status";
	private static final String MESSAGE = "message";
	private static final String DATA = "data";
	
	private boolean status = true; 	
	private String message = "";
	private static Map data = null;
	private static JSONObject jsonData = null;
	private static LoginResponse instance = null;
	private LoginResponse() {
		
	}
	public static LoginResponse getInstance(){
		if(instance==null){
			instance = new LoginResponse();
		}
		data = new HashMap();
		data.put(DATA, new JSONArray());
		jsonData = new JSONObject();
		return instance;
	}
	public LoginResponse setStatus(boolean status)
	{
		this.status= status;
		return instance;
	}
	public LoginResponse setMessage(String msg)
	{
		this.message= msg;
		return instance;
	}
	public LoginResponse setData(Object o)
	{
		if(o!=null){
			this.data.put("data",o);
		}

		return instance;
	}
	public LoginResponse setData(List list)
	{
		if(list!=null){
			this.data.put("data",list);
		}

		return instance;
	}
	public LoginResponse setData(JSONArray data)
	{
		this.data.put("data",data);
		return instance;
	}
	public LoginResponse setDtata(JSONObject data)
	{
		JSONArray ja =new JSONArray();
		ja.add(data);
		this.data.put("data", ja);
		return instance;
	}
	public boolean getStatus()
	{
		return this.status;
	}
	public String getMessage()
	{
		return this.message;
	}
	public Map getData()
	{
		return this.data;
	}
	public JSONObject getJSONData()
	{
		this.jsonData.put(STATUS, status);
		this.jsonData.put(MESSAGE, message);
		this.jsonData.put(DATA, data.get("data"));
		return this.jsonData;
	}
	public String toString()
	{
		return getJSONData().toString();
	}
}
